package com.day1;

import com.alibaba.fastjson.JSON;
import hk.JdbcUtil;
import com.entity1.MyUser;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/queryall")
public class QueryAll extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doGet(req, resp);
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        System.out.println("转页成功======");
        //不需要获取请求参数

        try {
            List<MyUser> list = JdbcUtil.queryAll();
            String s = JSON.toJSONString(list);
            System.out.println(s);
            resp.getWriter().print(s);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
